package com.huaxin.hxcloud.dialog;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

import com.huaxin.common.utils.ToastUtil;
import com.huaxin.hxcloud.R;
import com.huaxindata.common.base.HxBaseDialogFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * @author songxf
 * @date 2018/6/20
 * @Desc 结束任务单Dialog
 * Copyright HUAXIN DATA. All rights reserved.
 */
public class HxSPTFinishWorkDialog extends HxBaseDialogFragment {


    @BindView(R.id.title_id)
    TextView mTitleId;
    @BindView(R.id.des_tv)
    TextView mDesTv;
    @BindView(R.id.et_task_fee)
    EditText mEtTaskFee;
    @BindView(R.id.line_view)
    View     mLineView;
    @BindView(R.id.cancel_tv)
    TextView mCancelTv;
    @BindView(R.id.ensure_tv)
    TextView mEnsureTv;

    public void setOnUseMoneyClickListener(OnUseMoneyClickListener onUseMoneyClickListener) {
        mOnUseMoneyClickListener = onUseMoneyClickListener;
    }

    private OnUseMoneyClickListener mOnUseMoneyClickListener;

    public interface OnUseMoneyClickListener {
        void use(String money);
    }

    public static HxSPTFinishWorkDialog newInstance() {

        Bundle args = new Bundle();

        HxSPTFinishWorkDialog fragment = new HxSPTFinishWorkDialog();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int setRootViewId() {
        return R.layout.dialog_finish_work;
    }

    @Override
    public void initData() {

    }

    @Override
    public int showPosition() {
        return Gravity.CENTER;
    }


    @OnClick({R.id.cancel_tv, R.id.ensure_tv})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.cancel_tv:
                dismiss();
                break;
            case R.id.ensure_tv:
                String useMoney = mEtTaskFee.getText().toString().trim();
                if (mOnUseMoneyClickListener != null) {
                    mOnUseMoneyClickListener.use(useMoney);
                    dismiss();
                }
                break;
            default:
                break;
        }
    }

}
